package com.itheima.reflect.myreflect5;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        Class<?> clazz = Class.forName("com.itheima.reflect.myreflect5.Student");
        Method function4 = clazz.getMethod("function4", String.class);
        Student student = (Student) clazz.getConstructor().newInstance();
        Object result = function4.invoke(student, "zhangsan");
        System.out.println(result);
    }
}
